# -*- coding: utf-8 -*-
import scrapy

from dianying.items import DianyingItem

class DianyingSpider(scrapy.Spider):
    name = 'dianying'
    allowed_domains = ['dianying.2345.com/top/']
    start_urls = ['http://dianying.2345.com/top/']
    def parse(self, response):
        allli = response.xpath("//ul[contains(@class,'picList clearfix')]/li")
        for li in allli:
            item = DianyingItem()
            item['pic'] = li.xpath("./div[@class='pic']/img/@src").extract()[0]
            item['name'] = li.xpath('./div/a/@title').extract()[0]
            item['main_actor'] = li.xpath("./div/p[contains(@class,'pActor')]/a/text()").extract()[0]
            item['content'] = li.xpath("./div/p[contains(@class,'pTxt pIntroShow')]/text()").extract()[0]
            try:
                item['update_time'] = li.xpath("./div/p/span[contains(@class,'sIntro')]/text()").extract()[0]
            except:
                item['update_time'] = "没有上映时间"
            yield item